﻿using System;
using System.Collections.Generic;
using OpenTwitter.SDK.Sina;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenTwitter.SDK;

namespace guanggun.guanggun
{
    public partial class s : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && Session["sinaToken"] != null)
            {
                string sinatoken = Request.QueryString["oauth_token"].ToString();
                string sinaverifier = Request.QueryString["oauth_verifier"].ToString();//验证马
                OpenTwitter.SDK.Sina.OAuth sinaoauth = new OpenTwitter.SDK.Sina.OAuth(Session["sinaAppKey"].ToString(), Session["sinaAppSecret"].ToString());
                sinaoauth.Token = Session["sinaToken"].ToString();
                sinaoauth.TokenSecret = Session["sinaTokenSecret"].ToString();
                 AuthorizedUser user;
                if(sinaoauth.GetAccessToken(sinaverifier,out user))
                {
                    Context.Session["sinaAccessKey"] = sinaoauth.Token;
                    Context.Session["sinaAccessSecret"] = sinaoauth.TokenSecret;
                    Context.Session["sinaComfirm"] = "1";//认证成功
                    Session["sinaOauth"] = sinaoauth;
                    Session["type"] = "sina";
                    Response.Redirect("guanggun/guang.aspx");
                }
            }

        }
    }
}